<html>
<body onload = test();>
</body>
<script>

Function.prototype.before = function( func) {
     var _self = this;
     return function() {
           if ( func.apply( this, arguments ) === false ) {
                return false;
          }
          return _self.apply( this.arguments);
     }
}

Function.prototype.after = function( func ){
    var _self = this;
    return function() {
       var ret = _self.apply( this, arguments );
       if ( ret === false ) {
          return false;
       }
       func.apply( this, arguments);
       return ret;
    }
}

var append_doms = function() {
    for( var i = 0; i < 100000; i++) {
    	var div = document.createElement( "div");
        document.body.appendChild(div);
    }
};

var log_time = function( func, log_name) {
       return func = ( function() {
           var d;
           return func.before( function(){
                 d = new Date();
           }).after( function(){
                 console.log( log_name + ( new Date() - d));
           });
     })();
 };

function test() {
	log_time(append_doms, "consumed time: ")();
}

</script>
</html>